package com.exercise.AndroidCamera;

import java.io.File;
import java.net.URI;
import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.GridView;
import android.widget.ImageView;
/*
기능 : 이미지를 띄우는 기능을하는 어탭터
작성 : 하드캔
완료일 : 2014.09.26 
	*/
public class ImageAdapter extends BaseAdapter{

   private Context mContext;
   private ArrayList<Bitmap> mBitmap;
   WritePostActivity write = new WritePostActivity();
   
   public ImageAdapter(Context context, ArrayList<Bitmap> arrBitmap) {
   // TODO Auto-generated constructor stub
      mContext = context;
      mBitmap = arrBitmap;

   }

   @Override
   public int getCount() {
      // TODO Auto-generated method stub
      return mBitmap.size();
   }

   @Override
   public Object getItem(int position) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ImageView image;
      if(convertView == null){
         image = new ImageView(mContext);
         image.setLayoutParams(new GridView.LayoutParams((int)mContext.getResources().getDimension(R.dimen.wid), (int)mContext.getResources().getDimension(R.dimen.hei)));
         image.setScaleType(ImageView.ScaleType.CENTER_CROP);
         image.setPadding(0, 2, 0, 2);
      }
      else{
         image = (ImageView) convertView;
      }
      
      image.setImageBitmap(mBitmap.get(position));
      
      return image;
   }

}

